package com.boxuegu.domain;

import java.io.Serializable;
import java.util.Objects;

//水果类
public class Fruit implements Serializable {

    private static final long serialVersionUID = 3L;

    private String id;
    private String name;
    //价格
    private double price;
    //库存
    private int amount;

    public Fruit() {
    }

    public Fruit(String id, String name, double price, int amount) {
        this.id = id;
        this.name = name;
        this.price = price;
        this.amount = amount;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getAmount() {
        return amount;
    }

    public void setAmount(int amount) {
        this.amount = amount;
    }

    @Override
    public String toString() {
        return id + "      " + name + "      " + price + "      " + amount;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Fruit fruit = (Fruit) o;
        return Double.compare(fruit.price, price) == 0 &&
                amount == fruit.amount &&
                Objects.equals(id, fruit.id) &&
                Objects.equals(name, fruit.name);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, name, price, amount);
    }
}
